<?php
// ------------------------------------------------------------------------------------
// Bestand:       Index, indexController.php
// Versie:        1.1
// Projekt:       Cursus MasterClass van Eduvision
// Datum:         31-05-2008
// Auteur(s):     Richard lagendijk/Ronald Obbens
// Email(s):      r.lagendijk@hccnet.nl/ronaldobbens@gmail.com
// Revisie(s):	  1.1 -> extends controller
//
// Beschrijving:  Index pagina van de webpagina: Askkid-CF.
// ------------------------------------------------------------------------------------
//
//
// Start Smarty

require_once 'newsController.php';
require_once 'Controller.php';
require_once 'questionController.php';

class indexController extends Controller {
  protected $m_aNews;
  protected $m_aFaq;
  protected $m_sQuestion;

  public function __construct () 
  {
  	parent::__construct();
  }
  
  /**
   * Index action 
   * 
   * Default action of the indexController, shows the indexpage
   *
   */
  public function index ($p_sParameter = NULL) {
  	
    $news = new newsController();
    $questions = new questionController();
  	
    $this->m_sQuestion = $p_sParameter;
    
    $aQuestions = array();
   
  	foreach($questions->getLastQuestions(5) AS $question)
  	{
  		$aQuestions[] = '<a href="'.DOMAIN_URL.'/question/showitem/' . $question->getId() . '/' . $question->getquestion() . '">' . (string) $question->getQuestion() . '</a>';
  	}
 
  	$aNewsitems = array();
  	
  	foreach($news->getLastNewsItems(5) AS $newsitem)
  	{
  		$aNewsitems[] = '<a href="'.DOMAIN_URL.'/news/showitem/' . $newsitem->getId() . '/' . $newsitem->getTitle() . '">' . $newsitem->getTitle() . '</a>';
  	}
  	
  	$this->m_aNews = $aNewsitems;
    
    $this->m_aFaq = $aQuestions;

    parent::assign('news', $this->m_aNews);
    parent::assign('faq', $this->m_aFaq);
    parent::render('index.tpl');
  }
}
?>
